﻿//-----------------------------------------------------------------------
// <copyright file="ReportViewerPresenter.cs" company="Simnova LLC">
//     Copyright (c) Simnova LLC. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace Simnova.Collaborate.Presenter
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Simnova.Collaborate.View;
    

    public class ReportViewerPresenter
    {
        private IReportViewer reportViewerView;
        private int userId;

        public ReportViewerPresenter(IReportViewer reportViewerView, int userId)
        {
            this.reportViewerView = reportViewerView;
            this.userId = userId;
        }
        
        public byte[] ViewWeeklyReport()
        {
            AppServer.CollaborateServiceClient collaborateClient = new Simnova.Collaborate.Presenter.AppServer.CollaborateServiceClient();
            AppServer.ReportParameter[] reportParameters = new Simnova.Collaborate.Presenter.AppServer.ReportParameter[2];

            reportParameters[0] = new Simnova.Collaborate.Presenter.AppServer.ReportParameter();
            reportParameters[0].Name = "userId";
            reportParameters[0].Value = this.userId.ToString();

            reportParameters[1] = new Simnova.Collaborate.Presenter.AppServer.ReportParameter();
            reportParameters[1].Name = "endDate";
            reportParameters[1].Value = this.reportViewerView.WeeklyReportEndDate.ToShortDateString();

            return collaborateClient.ExecuteReport("/Simnova.Collaborate.Reports/WeeklyTimeReport", reportParameters, "PDF");
        }
    }
}
